import 'package:agro_sklad_new/feature/domain/usercases/get_all_stock.dart';
import 'package:agro_sklad_new/feature/presentations/home/controller/home_controller.dart';
import 'package:get_it/get_it.dart';
import 'package:internet_connection_checker/internet_connection_checker.dart';
import 'package:http/http.dart' as http;
import 'core/platform/networl_info.dart';
import 'feature/data/datasources/stock/stock_remoute_data_sourse.dart';
import 'feature/data/repositories/stock_repository_impl.dart';
import 'feature/domain/repositories/stock_repository.dart';

final sl = GetIt.instance;


Future<void> init() async {
  // Cubit
  sl.registerFactory(
        () => HomeCubit(getAllStock: sl()),
  );


  // UseCases
  sl.registerLazySingleton(() => GetAllStock(sl()));

  // Repository
  sl.registerLazySingleton<StockRepository>(
        () => StockRepositoryImpl(
          remoteDataSource: sl(),
          networkInfo: sl(),
    ),
  );

  sl.registerLazySingleton<StockRemoteDataSource>(
        () => StockRemoteDataSourceImpl(
      client: sl(),
    ),
  );

  // sl.registerLazySingleton<StockLocalDataSource>(
  //       () => PersonLocalDataSourceImpl(sharedPreferences: sl()),
  // );

  // Core
  sl.registerLazySingleton<NetworkInfo>(
        () => NetworkInfoImp(sl()),
  );

  // External
  // final sharedPreferences = await SharedPreferences.getInstance();
  // sl.registerLazySingleton(() => sharedPreferences);
  sl.registerLazySingleton(() => http.Client());
  sl.registerLazySingleton(() => InternetConnectionChecker());
}
